#include "a8255.h"
#include "printer.h"
#include <stdio.h>

void print_char(unsigned char *data)
{
    if(*data >= ' ' || *data == '\n'){
        _8255_OUT(CTRL, RSTB);
        _8255_OUT(PA, *data);
        _8255_OUT(CTRL, STB);
    }
}

void print(unsigned char *buffer)
{
    unsigned char *data = buffer;
    
    printf("Print String:%s\n", buffer);
    
    _8255_OUT(CTRL, CTRL_WORD);
    
    printf("CTRL word sent\n");
    
    for( ; *data != '\0'; data++){
        print_char(data);
        printf("Char [%c] sent\n",*data);
        _8255_LOOP_QUERY(MASK);
        printf("printed\n");
    }
}

